/**
 * Created by cr. on 2017/8/29.
 * 用于拦截并记录访问日志
 */
const log4js = require('koa-log4'),
    logger = require('lib/logger');

/**
 * koa access log
 * @param  {...[type]} arg [description]
 * @return {[type]}        [description]
 */
let koaLogger = function(...arg) {
    let accessFmt = ':remote-addr - -' +
        ' ":method :url HTTP/:http-version"' +
        ' :status :content-length ":referrer"' +
        ' ":user-agent" :response-time' +
        ' \n\r--------------------------------\n\r';
    arg.push(accessFmt);
    return log4js.koaLogger.apply(this, arg);
}

module.exports = koaLogger(logger);